import Vue from "vue";
import Vuex, { Store } from "vuex";
import createLogger from "vuex/dist/logger";
import VuexPersistence from "vuex-persist";
import userInfo from "./user/userInfo";
import ontologyModel from "./ontologyModel/index";
import config from "./config";
import server from "./config/server";
import permission from "./config/permission";
import knowledgeMap from "./knowledgeMap/index.js";
import modelDesign from "./dataReceive/modelDesign";
import dataCollection from "./dataReceive/dataCollection";
import dataAggregation from "./dataReceive/dataAggregation";
import search from "./search/search";

Vue.use(Vuex);

const vuexlocal = new VuexPersistence({
  key: "konwladge",
  storage: window.sessionStorage,
  reducer: (state) => {
    return {
      server: state.server,
      // dataCollection:state.dataCollection
      // ontologyModel: state.ontologyModel,
    };
  },
});

// let plugins = [vuexlocal.plugin, myPlugin]
let plugins = [vuexlocal.plugin];
if (process.env.NODE_ENV === "development") {
  // plugins.push(createLogger());
}

const store = new Store({
  // strict: process.env.NODE_ENV !== "production",
  plugins,
  modules: {
    config: {
      namespaced: true,
      ...config,
    },
    userInfo: {
      namespaced: true,
      ...userInfo,
    },
    ontologyModel: {
      namespaced: true,
      ...ontologyModel,
    },
    server: {
      namespaced: true,
      ...server,
    },
    permission: {
      namespaced: true,
      ...permission,
    },
    knowledgeMap: {
      namespaced: true,
      ...knowledgeMap,
    },
    modelDesign: {
      namespaced: true,
      ...modelDesign,
    },
    dataCollection: {
      namespaced: true,
      ...dataCollection,
    },
    dataAggregation: {
      namespaced: true,
      ...dataAggregation,
    },
    search: {
      namespaced: true,
      ...search,
    },
  },
});
export default store;
